package com.edu.exam.entity.examination.paper.technical;

// import com.edu.exam.enums.*; // TODO: 修复缺失的枚举类
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import java.time.LocalDateTime;

/**
 * OMR识别结果实体类
 * [所属模块] E-04 扫描阅卷处理模块
 * 对应数据库表：om_recognition_result
 *
 * 根据E-04扫描阅卷处理模块设计实现
 * 存储单张答题卡的OMR识别结果信息，包括考号识别结果、客观题答案识别结果、质量评估等。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class OmRecognitionResult {

    /**
     * 结果ID，主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "result_id")
    private Long resultId;

    /**
     * 关联信息
     */
    @Column(name = "task_id", nullable = false)
    private Long taskId;

    @Column(name = "sheet_id", nullable = false)
    private Long sheetId;

    @Column(name = "original_image_id", nullable = false)
    private Long originalImageId;

    /**
     * 结果基本信息
     */
    @Column(name = "result_name", length = 200, nullable = false)
    private String resultName;

    @Column(name = "sheet_number", length = 100)
    private String sheetNumber;

    /**
     * 识别统计
     */
    @Column(name = "total_questions")
    private Integer totalQuestions;

    @Column(name = "recognized_questions")
    private Integer recognizedQuestions;

    @Column(name = "failed_questions")
    private Integer failedQuestions;

    @Column(name = "uncertain_questions")
    private Integer uncertainQuestions;

    /**
     * 质量评估
     */
    @Column(name = "overall_quality_score", precision = 5, scale = 2)
    private Double overallQualityScore;

    // @Enumerated(EnumType.STRING) // 暂时注释，使用String
    @Column(name = "quality_level", length = 20)
    private String qualityLevel;

    @Column(name = "confidence_threshold", precision = 5, scale = 2)
    private Double confidenceThreshold;

    @Column(name = "average_confidence", precision = 5, scale = 2)
    private Double averageConfidence;

    /**
     * 处理状态
     */
    // @Enumerated(EnumType.STRING) // 暂时注释，使用String
    @Column(name = "processing_status", length = 20, nullable = false)
    private String processingStatus;

    // @Enumerated(EnumType.STRING) // 暂时注释，使用String
    @Column(name = "verification_status", length = 20)
    private String verificationStatus;

    // @Enumerated(EnumType.STRING) // 暂时注释，使用String
    @Column(name = "review_status", length = 20)
    private String reviewStatus;

    /**
     * 处理信息
     */
    @Column(name = "recognition_start_time")
    private LocalDateTime recognitionStartTime;

    @Column(name = "recognition_end_time")
    private LocalDateTime recognitionEndTime;

    @Column(name = "processing_duration_ms")
    private Integer processingDurationMs;

    @Column(name = "algorithm_used", length = 100)
    private String algorithmUsed;

    /**
     * 异常信息
     */
    @Column(name = "error_code", length = 50)
    private String errorCode;

    @Column(name = "error_message", columnDefinition = "TEXT")
    private String errorMessage;

    @Column(name = "retry_count")
    private Integer retryCount;

    /**
     * 时间信息
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createdTime;

    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 校验信息
     */
    @Column(name = "manual_review_required")
    private Boolean manualReviewRequired;

    @Column(name = "manual_review_time")
    private LocalDateTime manualReviewTime;

    @Column(name = "manual_review_by")
    private Long manualReviewBy;

    // @Enumerated(EnumType.STRING) // 暂时注释，使用String
    @Column(name = "manual_review_result", length = 20)
    private String manualReviewResult;

    @Column(name = "manual_review_notes", columnDefinition = "TEXT")
    private String manualReviewNotes;


}